package com.spider.util;

import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import org.json.JSONObject;

import java.util.Map;

public class HttpRequestUtil {

    public static JSONObject post(String requestURL,
                                  Map<String,String> header) {
        JSONObject jsonObject = null;
        try {
            HttpResponse<JsonNode> response = Unirest.post(requestURL)
                    .headers(header)
                    .asJson();

            return response.getBody().getObject();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return jsonObject;
    }

}
